Skip to content

fix(cli): declare --config-file for fpm export - #1414

Merged
perazz merged 2 commits into
fortran-lang:mainfrom
perazz:fix/export-config-file
Nov 15, 2026
Merged

perazz merged 2 commits into
fortran-lang:mainfrom
perazz:fix/export-config-file

Conversation

@perazz

@perazz perazz commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Fixes #1413.

Since v0.13.0, fpm export does nothing and exits 0: fpm export --manifest m.json writes no m.json. A gfortran build prints nothing; a flang build prints Fortran STOP.

  • build_settings (added in 1dfc4ec) reads sget('config-file'), but the export prototype never declared --config-file. M_CLI2 then stops with a bare stop (exit status 0) before cmd_export runs.
  • Declare --config-file " " for export, as build, run, test, install, update, clean and publish already do. export then reads it like build does: build_model passes it to the global settings.
  • All other keys build_settings reads are already declared through common_args and compiler_args. dump is read only when specified('dump'), which returns false for an undeclared key, so export does not need it.

Since fpm export was added (v0.10.1), --manifest, --model and --dependencies defaulted to the string "filename", so cmd_export always saw all three as given:

  • fpm export --manifest m.json also resolved the dependencies, built the model and wrote both to ./filename.
  • fpm export --model, with no file name, crashed with a segmentation fault (gfortran 16).

They now default to blank, and cmd_export writes only the files it is given a name for. With none (fpm export, or fpm export --model alone), it prints <INFO> *cmd_export* exiting: no manifest/model/dependencies keyword provided and exits 0, as that code was written to do.

ci/run_tests.sh: fpm export -C hello_world must write manifest.json for --manifest, and model.json and dependencies.json for --model and --dependencies, without creating filename. The cli-test case export --manifest manifest.json --flag "-O2" did not catch either bug. The child process stopped before writing _test_cli, and the parent read the previous test's results instead.

Verification

macOS arm64, gfortran 16.2 and flang 23 (Homebrew):

  • The new ci/run_tests.sh check fails without the fix:

    • on main, test -f hello_world/manifest.json fails with both compilers, because export exits 0 without writing it;
    • with only --config-file declared, test ! -e hello_world/filename fails with gfortran 16.
  • With the fix, fpm test passes with both compilers, and ci/run_tests.sh <fpm> passes with gfortran 16.

  • In a scratch package, with --config-file declared, before and after the new defaults (gfortran 16; the fixed flang 23 build gives the same results):

    command before after
    fpm export --manifest m.json writes m.json, ./filename and build/ writes m.json only
    fpm export --model mo.json writes mo.json, ./filename and build/ writes mo.json and build/
    fpm export --model segmentation fault, exit 139 <INFO> message, exit 0
    fpm export writes ./filename and build/, exit 0 <INFO> message, exit 0

`fpm export` read `config-file` through the shared build settings
helper, but its command-line prototype did not declare the option.
M_CLI2 then stopped with exit status 0 before anything was exported,
so `fpm export --manifest m.json` wrote nothing and reported success.

Declare `--config-file` for `export` as the other build subcommands do,
and check in ci/run_tests.sh that `fpm export --manifest` writes the
file.
@perazz perazz added this to the v0.14.0 milestone Nov 14, 2026
--manifest, --model and --dependencies defaulted to "filename", so
cmd_export always exported all three. The files that were not asked for
went to ./filename, and --model without a file name crashed. They now
default to blank, and cmd_export writes only the files it is given a
name for.

ci/run_tests.sh checks that each option writes its file and that no
./filename is created.
@perazz
perazz merged commit ceb133e into fortran-lang:main Nov 15, 2026
44 checks passed
@perazz
perazz deleted the fix/export-config-file branch November 15, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fpm export writes nothing and exits 0

1 participant